<?php


namespace App\Services;


class GoodsService
{
    //小程序商品详情redis_key
    const GOODS_INFO_KEY = 'goods_info';

    //操作类型
    const GOODS_SAVE_DRAFT = 1;//保存草稿
    const GOODS_PUBLISH = 2;//发布商品
    const GOODS_SAVE_SETMEAL = 3;//保存套餐

    //是否在小程序显示
    const GOODS_IS_SHOW_YES = 1;
    const GOODS_IS_SHOW_NO = 2;

    //商品列表
    const GOODS_PUT_LIST = 1;//已上架
    const GOODS_OFF_LIST = 2;//已下架
    const GOODS_CHECK_LIST = 3;//审核中

    //商品审核状态
    const GOODS_CHECK_STATUS_DRAFT = 1;//草稿箱
    const GOODS_CHECK_STATUS_NOT_SUBMIT = 2;//未提审
    const GOODS_CHECK_STATUS_NO = 3;//待审核
    const GOODS_CHECK_STATUS_CHECKED = 4;//已审核
    const GOODS_CHECK_STATUS_REFUSE = 5;//审核拒绝

    const GOODS_CHECK_STATUS_NAME_LIST = [
        '1'=>'草稿箱',
        '2'=>'未提审',
        '3'=>'待审核',
        '4'=>'已审核',
        '5'=>'审核拒绝',
    ];

    //商品状态
    const GOODS_STATUS_PUT = 1;//上架
    const GOODS_STATUS_OFF = 2;//下架
    const GOODS_STATUS_APPLY_OFF = 3;//申请下架
    const GOODS_STATUS_OFF_REFUSE = 4;//申请下架拒绝
    const GOODS_STATUS_VIOLATION_OFF = 5;//违规下架

    const GOODS_STATUS_NAME_LIST = [
            '1'=>'上架',
            '2'=>'下架',
            '3'=>'申请下架',
            '4'=>'申请下架拒绝',
            '5'=>'违规下架',
        ];
    const GOODS_STATUS_CHECK_LIST = [
        '2'=>'已审核',
        '3'=>'未审核',
        '4'=>'已拒绝',
    ];


    //碎屏险
    const GOODS_INSURANCE_ONE = '1';//一年碎屏险
    const GOODS_INSURANCE_TWO = '2';//两年碎屏险
    const GOODS_INSURANCE_SEVEN = '7';//无碎屏险

    const GOODS_INSURANCE_LIST = [
//        '1'=>'意外保障¥299',
//        '2'=>'意外保障¥399',
        '4'=>'意外保障¥499',
    ];
    const GOODS_INSURANCE_LIST_SHOW = [
        '1'=>'意外保障¥299',
        '2'=>'意外保障¥399',
        '4'=>'意外保障¥499',
        '7'=>'不购意外保障',
        '100'=>'其他',
    ];
    const GOODS_RENT_LIST_SHOW = [
        '1'=>'首月一元',
        '2'=>'首月五折',
        '7'=>'不参与活动'
    ];
    //碎屏险金额
    const GOODS_INSURANCE_MONEY_LIST = [
        '100'=>'0',
        '1'=>'299.00',
        '2'=>'399.00',
        '3'=>'599.00',
        '4'=>'499',
        '7'=>'0'
    ];

    //联通5G冲浪卡
    const GOODS_UNIWAP_MONTH_ONE = '1';//月租139元
    const GOODS_UNIWAP_MONTH_TWO = '2';//月租209元
    const GOODS_UNIWAP_MONTH_THREE = '3';//月租279元
    const GOODS_UNIWAP_MONTH_SEVEN = '7';//无选联通卡

    const GOODS_UNIWAP_LIST = [
        '1'=>'月租139元',
        '2'=>'月租209元',
        '3'=>'月租279元',
    ];
    const GOODS_UNIWAP_MONTH_LIST_SHOW = [
        '1'=>'月租139元',
        '2'=>'月租209元',
        '3'=>'月租279元',
        '7'=>'不购买联通卡'
    ];
    //联通卡金额
    const GOODS_UNIWAP_MONTH_LIST = [
        '1'=>'139.00',
        '2'=>'209.00',
        '3'=>'279.00',
        '7'=>'0'
    ];
    //审核类型
    const GOODS_CHECK_TYPE = 1;//商品审核
    const GOODS_OFF_CHECK_TYPE = 2;//下架审核
    const GOODS_CHECK_TYPE_LIST = [
        '1'=>'商品审核',
        '2'=>'下架审核',
    ];

    //审核状态
    const GOODS_NO_CHECK_STATUS = 1;//未审核
    const GOODS_REFUSE_CHECK_STATUS = 2;//审核未通过
    const GOODS_CHECK_STATUS_LIST = [
        '1'=>'未审核',
        '2'=>'审核未通过',
    ];

    //租金形式
    const GOODS_PACT_TYPE_RETURN = 3;//随租随还
    const GOODS_PACT_TYPE_FIXED = 1;//固定租期
    const GOODS_PACT_TYPE_GIVE = 2;//租完即送

    const GOODS_PACT_TYPE_NAME_LIST = [
        '1'=>'固定租期',
        '2'=>'租完即送'
    ];

    //租金方法
    const GOODS_RENT_TYPE_MONTH = 1;//按月租
    const GOODS_RENT_TYPE_DAY = 2;//按天租
    const GOODS_RENT_TYPE_CUSTOM = 3;//自定义
    const GOODS_RENT_TYPE_MANAGER_CUSTOM = 4;//后台修改租期后自定义

    const GOODS_RENT_TYPE_NAME_LIST = [
        '1'=>'按月',
        '2'=>'按天',
        '3'=>'自定义租期',
    ];

    //是否下架审核
    const GOODS_SHELF_CHECK = 1;//是
    const GOODS_NO_SHELF_CHECK = 2;//否

    //商品寄出邮费类型
    const GOODS_SEND_CONVEY_TYPE_PARCEL = 1;//包邮
    const GOODS_SEND_CONVEY_TYPE_COLLECT = 2;//到付（自付）

    const GOODS_SEND_CONVEY_TYPE_NAME_LIST = [
        '1'=>'包邮',
        '2'=>'到付（自付）',
        '3'=>'到店自取',
    ];

    //商品归还邮费类型
    const GOODS_RETURN_CONVEY_TYPE_PARCEL = 1;//包邮
    const GOODS_RETURN_CONVEY_TYPE_COLLECT = 2;//到付（自付）

    const GOODS_RETURN_CONVEY_TYPE_NAME_LIST = [
        '1'=>'包邮',
        '2'=>'自付',
        '3'=>'无',
    ];

    //商品列表排序
    const GOODS_SORT_COMPREHENSIVE = 1;//综合排序
    const GOODS_SORT_PRICE_ASC = 2;//价格升序
    const GOODS_SORT_PRICE_DESC = 3;//价格降序
    const GOODS_SORT_PRICE_NEW = 4;//最新

    const GOODS_SORT_TYPE_NAME_LIST = [
        '1' => 'update_time',
        '2' => 'min_price',
        '3' => 'min_price',
        '4' => 'id',
    ];

    const GOODS_SORT_UP_DOWN_LIST = [
        '1' => 'desc',
        '2' => 'ASC',
        '3' => 'desc',
        '4' => 'desc',
    ];

    //商品套餐租期花呗等删除状态
    const GOODS_DELETE_STATUS = 1;//删除
    const GOODS_NO_DELETE_STATUS = 2;//未删除

    //商品套餐是否支持花呗
    const GOODS_SETMEAL_IS_HUABEI = 1;//是
    const GOODS_SETMEAL_NO_HUABEI = 2;//否

    const GOODS_HUABEI_NAME_LIST = [
        '1'=>'开启',
        '2'=>'关闭'
    ];

    //商品是否可买断
    const GOODS_BUYOUT_YES = 2;//不可买断
    const GOODS_BUYOUT_NO = 1;//可买断

    const GOODS_BUYOUT_NAME_LIST = [
        '1'=>'可买断',
        '2'=>'不可买断'
    ];

    //新旧程度
    const GOODS_NEW_GRADE_NAME_LIST = [
        '100'=>'全新',
        '990'=>'99准新',
        '99'=>'99新',
        '98'=>'98新',
        '95'=>'95新',
        '90'=>'9新',
        '85'=>'85新'
    ];

    //花呗手续费承担
    const GOODS_HUABEI_FEE_MERCHANT = 1;//商户
    const GOODS_HUABEI_FEE_USER = 2;//用户
    const GOODS_HUABEI_FEE_CLOSE = 3;//关闭
    const GOODS_HUABEI_FEE_LIST = [
        '1'=>'商户',
        '2'=>'用户',
        '3'=>'关闭'
    ];

    //起租日
    const GOODS_START_DATE_LIST = [
        0,1,2,3,4,5,6,7,10,15
    ];

    //扣款周期
    const GOODS_WITHHOLD_CYCLE_LIST = [
        15,30
    ];

    //租期设置  按月
    const GOODS_LEASE_TERM_MONTH_LIST = [
        1,3,6,9,12
    ];
    //租期设置  按天 换算租期
    const GOODS_LEASE_DAY_LIST = [
        '1'=>'1',
        '7'=>'1',
        '15'=>'1',
        '30'=>'1',
        '90'=>'3',
        '120'=>'4',
        '180'=>'6',
        '270'=>'9',
        '365'=>'12'
    ];

    //推荐活动
    const GOODS_ACTIVITY_LIST = [1,2,3,4];
    const GOODS_ACTIVITY_NAME_LIST = [
        '1'=>'商城商品推荐',
        '2'=>'手机端商品推荐',
        '3'=>'小程序商品推荐',
        '4'=>'芝麻信用商品推荐',
    ];

    //推荐活动对应图标
    const GOODS_ACTIVITY_IMG_LIST = [
        '1'=>'/img/20210601114920_81036.png',//商城商品推荐
        '2'=>'/img/20210601114934_41794.png',//手机端商品推荐
        '3'=>'/img/20210610170112_76067.png',//小程序商品推荐
        '4'=>'/img/20210601114813_41424.png',//芝麻信用商品推荐
    ];

    //租赁标签
    const GOODS_RENT_LABEL_NAME_LIST = [
        '包邮','可买断','保险','免赔','提前归还','上门安装','七天无理由退换'
    ];


    //获取商品状态名称
    public static function getGoodsStatusName($goodsStatus){
        if(!empty($goodsStatus)){
            $list = self::GOODS_STATUS_NAME_LIST;
            return $list[$goodsStatus];
        }
    }

    //获取商品租金形式
    public static function getGoodsPactName($pactType){
        if(!empty($pactType)){
            $list = self::GOODS_PACT_TYPE_NAME_LIST;
            return $list[$pactType];
        }
    }

    //获取商品租金形式
    public static function getGoodsRentTypeName($rentType){
        if(!empty($rentType)){
            $list = self::GOODS_RENT_TYPE_NAME_LIST;
            return $list[$rentType];
        }
    }

    //获取商品寄出邮费类型
    public static function getGoodsSendTypeName($convey_type){
        if(!empty($convey_type)){
            $list = self::GOODS_SEND_CONVEY_TYPE_NAME_LIST;
            return $list[$convey_type];
        }
    }
    //获取商品归还邮费类型
    public static function getGoodsReturnTypeName($convey_type){
        if(!empty($convey_type)){
            $list = self::GOODS_RETURN_CONVEY_TYPE_NAME_LIST;
            return $list[$convey_type];
        }
    }
    //获取商品是否可买断
    public static function getGoodsBuyoutName($is_buy_out){
        if(!empty($is_buy_out)){
            $list = self::GOODS_BUYOUT_NAME_LIST;
            return $list[$is_buy_out];
        }
    }

    //获取商品是否支持花呗
    public static function getGoodsIsHuabei($is_huabei){
        if(!empty($is_huabei)){
            $list = self::GOODS_HUABEI_NAME_LIST;
            return $list[$is_huabei];
        }
    }

    //获取商品审核状态
    public static function getGoodsCheckStatus($ischeck){
        if(!empty($ischeck)){
            $list = self::GOODS_CHECK_STATUS_NAME_LIST;
            return $list[$ischeck];
        }
    }

    //获取商品活动
    public static function getGoodsActivity($activity_type){
        if(!empty($activity_type)){
            $list = self::GOODS_ACTIVITY_NAME_LIST;
            return $list[$activity_type];
        }
    }
    //获取商品活动图标
    public static function getGoodsActivityImg($activity_type){
        if(!empty($activity_type)){
            $list = self::GOODS_ACTIVITY_IMG_LIST;
            return $list[$activity_type];
        }
    }

    //获取商品新旧程度
    public static function getGoodsNewGrade($new_grade){
        if(!empty($new_grade)){
            $list = self::GOODS_NEW_GRADE_NAME_LIST;
            return $list[$new_grade];
        }
    }


    //获取碎屏险金额
    public static function getGoodsInsurance($insurance,$is_insurance_choose_custom=0){

        if(!empty($insurance)){
            if($insurance==100){
                return $is_insurance_choose_custom;
            }
            $list = self::GOODS_INSURANCE_MONEY_LIST;
            return $list[$insurance];
        }
    }

    public static function getGoodsInsuranceName($insurance){
        if(!empty($insurance)){
            $list = self::GOODS_INSURANCE_LIST_SHOW;
            return $list[$insurance];
        }
    }


}
